package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ByStandardDemonstration;
import com.ruoyi.system.service.IByStandardDemonstrationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标准示范点Controller
 * 
 * @author ruoyi
 * @date 2024-03-12
 */
@RestController
@RequestMapping("/system/demonstration")
public class ByStandardDemonstrationController extends BaseController
{
    @Autowired
    private IByStandardDemonstrationService byStandardDemonstrationService;

    /**
     * 查询标准示范点列表
     */
    @PreAuthorize("@ss.hasPermi('system:demonstration:list')")
    @GetMapping("/list")
    public TableDataInfo list(ByStandardDemonstration byStandardDemonstration)
    {
        startPage();
        List<ByStandardDemonstration> list = byStandardDemonstrationService.selectByStandardDemonstrationList(byStandardDemonstration);
        return getDataTable(list);
    }

    /**
     * 导出标准示范点列表
     */
    @PreAuthorize("@ss.hasPermi('system:demonstration:export')")
    @Log(title = "标准示范点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ByStandardDemonstration byStandardDemonstration)
    {
        List<ByStandardDemonstration> list = byStandardDemonstrationService.selectByStandardDemonstrationList(byStandardDemonstration);
        ExcelUtil<ByStandardDemonstration> util = new ExcelUtil<ByStandardDemonstration>(ByStandardDemonstration.class);
        util.exportExcel(response, list, "标准示范点数据");
    }

    /**
     * 获取标准示范点详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:demonstration:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(byStandardDemonstrationService.selectByStandardDemonstrationById(id));
    }

    /**
     * 新增标准示范点
     */
    @PreAuthorize("@ss.hasPermi('system:demonstration:add')")
    @Log(title = "标准示范点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ByStandardDemonstration byStandardDemonstration)
    {
        return toAjax(byStandardDemonstrationService.insertByStandardDemonstration(byStandardDemonstration));
    }

    /**
     * 修改标准示范点
     */
    @PreAuthorize("@ss.hasPermi('system:demonstration:edit')")
    @Log(title = "标准示范点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ByStandardDemonstration byStandardDemonstration)
    {
        return toAjax(byStandardDemonstrationService.updateByStandardDemonstration(byStandardDemonstration));
    }

    /**
     * 删除标准示范点
     */
    @PreAuthorize("@ss.hasPermi('system:demonstration:remove')")
    @Log(title = "标准示范点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(byStandardDemonstrationService.deleteByStandardDemonstrationByIds(ids));
    }
}
